import pymysql
class db():
    def __init__(self,host,user,password,database):
        self.con=pymysql.connect(host=host,user=user,password=password,database=database)
        self.cur=self.con.cursor()

    def select_sql(self,sql):
        self.cur.execute(sql)
        return self.cur.fetchall()

    def close(self):
        # 关闭游标
        self.cur.close()
        # 关闭连接
        self.con.close()
